package com.jboost.modules.app.service.strategry.hx.sqlserver;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class SyncHx {
    public static void main(String[] args) {
        try {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            String url = "jdbc:sqlserver://1552757.iego.vip:19348;databaseName=AIS20230913103443";
            String username = "sa";
            String password = "123";
            Connection connection = DriverManager.getConnection(url, username, password);

            Statement statement = connection.createStatement();
            String sql = "SELECT * FROM t_Rpt_Content";
            ResultSet resultSet = statement.executeQuery(sql);
            while (resultSet.next()) {

                String name = resultSet.getString("FRptName");
                // 处理每一条查询结果
                System.out.println(name);
            }
            //Statement statement = connection.createStatement()) {
            //            String sql = "INSERT INTO employees (id, name, age) VALUES (1, 'John Doe', 30)";
            //            int rowsAffected = statement.executeUpdate(sql);
            //-----------------------------------
            resultSet.close();
            statement.close();
            connection.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
